package org.jeecg.modules.basesource.utils.cwbb;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.basesource.entity.SbCwbbXqykjzzLrb;
import org.jeecg.modules.basesource.entity.SbCwbbXqykjzzXjllb;
import org.jeecg.modules.basesource.entity.SbCwbbXqykjzzZcfzb;
import org.jeecg.modules.dzswj.vo.response.cwbb.*;

import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 小企业会计准则包装类
 * @author chensherun on 2022/3/2.
 * @version 1.0
 */
@Slf4j
public class CwbbXqyWrapperUtil {

    /**
     * 包装小企业会计准则利润表
     * @param lrb
     * @param nsrForm
     * @param gridlbList
     */
    public static void wrapperXqykjzzLrb(SbCwbbXqykjzzLrb lrb, NsrxxForm nsrForm, List<XqylrbnbGridlb> gridlbList) {
        Map<String, XqylrbnbGridlb> ewbhxhMap = gridlbList.stream().collect(Collectors.toMap(XqylrbnbGridlb::getEwbhxh, Function.identity(), (e1, e2) -> e2));
        if (nsrForm != null) {
            try {
                if (StringUtils.isNotBlank(nsrForm.getBsrq())) {
                    lrb.setBsrq(DateUtils.parseDate(nsrForm.getBsrq(), "yyyy-MM-dd"));
                }
            } catch (ParseException e) {
                log.error("日期转换有误:" + nsrForm.getBsrq());
            }
            lrb.setBbssq(nsrForm.getBbssq());
        }
        lrb.setSjcjSj(new Date());

        //1 一、营业收入
        lrb.setYyysrBnljje(getLrbBnljje(ewbhxhMap, 1));
        lrb.setYyysrByje(getLrbByje(ewbhxhMap, 1));
        //2 减：营业成本
        lrb.setJyycbBnljje(getLrbBnljje(ewbhxhMap, 2));
        lrb.setJyycbByje(getLrbByje(ewbhxhMap, 2));
        //3 税金及附加
        lrb.setYysjjfjBnljje(getLrbBnljje(ewbhxhMap, 3));
        lrb.setYysjjfjByje(getLrbByje(ewbhxhMap, 3));
        //4 其中：消费税
        lrb.setQzxfsBnljje(getLrbBnljje(ewbhxhMap, 4));
        lrb.setQzxfsByje(getLrbByje(ewbhxhMap, 4));
        //5 营业税
        lrb.setYysBnljje(getLrbBnljje(ewbhxhMap, 5));
        lrb.setYysByje(getLrbByje(ewbhxhMap, 5));
        //6 城市维护建设税
        lrb.setCswhjssBnljje(getLrbBnljje(ewbhxhMap, 6));
        lrb.setCswhjssByje(getLrbByje(ewbhxhMap, 6));
        //7 资源税
        lrb.setZysBnljje(getLrbBnljje(ewbhxhMap, 7));
        lrb.setZysByje(getLrbByje(ewbhxhMap, 7));
        //8 土地增值税
        lrb.setTdzzsBnljje(getLrbBnljje(ewbhxhMap, 8));
        lrb.setTdzzsByje(getLrbByje(ewbhxhMap, 8));
        //9 城镇土地使用税、房产税、车船税、印花税
        lrb.setCztdsysfcsccsyhsBnljje(getLrbBnljje(ewbhxhMap, 9));
        lrb.setCztdsysfcsccsyhsByje(getLrbByje(ewbhxhMap, 9));
        //10 教育费附加、矿产资源补偿费、排污费
        lrb.setJyffjkczybcfpwfBnljje(getLrbBnljje(ewbhxhMap, 10));
        lrb.setJyffjkczybcfpwfByje(getLrbByje(ewbhxhMap, 10));
        //11 销售费用
        lrb.setXsfyBnljje(getLrbBnljje(ewbhxhMap, 11));
        lrb.setXsfyByje(getLrbByje(ewbhxhMap, 11));
        //12 其中：商品维修费
        lrb.setQzspwxfBnljje(getLrbBnljje(ewbhxhMap, 12));
        lrb.setQzspwxfByje(getLrbByje(ewbhxhMap, 12));
        //13 广告费和业务宣传费
        lrb.setGgfhywxcfBnljje(getLrbBnljje(ewbhxhMap, 13));
        lrb.setGgfhywxcfByje(getLrbByje(ewbhxhMap, 13));
        //14 管理费用
        lrb.setGlfyBnljje(getLrbBnljje(ewbhxhMap, 14));
        lrb.setGlfyByje(getLrbByje(ewbhxhMap, 14));
        //15 其中：开办费
        lrb.setQzkbfBnljje(getLrbBnljje(ewbhxhMap, 15));
        lrb.setQzkbfByje(getLrbByje(ewbhxhMap, 15));
        //16 业务招待费
        lrb.setYwzdfBnljje(getLrbBnljje(ewbhxhMap, 16));
        lrb.setYwzdfByje(getLrbByje(ewbhxhMap, 16));
        //17 研究费用
        lrb.setYjfyBnljje(getLrbBnljje(ewbhxhMap, 17));
        lrb.setYjfyByje(getLrbByje(ewbhxhMap, 17));
        //18 财务费用
        lrb.setCwfyBnljje(getLrbBnljje(ewbhxhMap, 18));
        lrb.setCwfyByje(getLrbByje(ewbhxhMap, 18));
        //19 其中:利息费用(收入以–填列)
        lrb.setQzlxfysryhtlBnljje(getLrbBnljje(ewbhxhMap, 19));
        lrb.setQzlxfysryhtlByje(getLrbByje(ewbhxhMap, 19));
        //20 加：投资收益(亏损以–填列)
        lrb.setJtzsyssyhtlBnljje(getLrbBnljje(ewbhxhMap, 20));
        lrb.setJtzsyssyhtlByje(getLrbByje(ewbhxhMap, 20));
        //21 二、营业利润(亏损以–号填列)
        lrb.setEyylrksyhtlBnljje(getLrbBnljje(ewbhxhMap, 21));
        lrb.setEyylrksyhtlByje(getLrbByje(ewbhxhMap, 21));
        //22 加：营业外收入
        lrb.setJyywsrBnljje(getLrbBnljje(ewbhxhMap, 22));
        lrb.setJyywsrByje(getLrbByje(ewbhxhMap, 22));
        //23 其中：政府补助
        lrb.setQzzfbzBnljje(getLrbBnljje(ewbhxhMap, 23));
        lrb.setQzzfbzByje(getLrbByje(ewbhxhMap, 23));
        //24 减：营业外支出
        lrb.setJyywzcBnljje(getLrbBnljje(ewbhxhMap, 24));
        lrb.setJyywzcByje(getLrbByje(ewbhxhMap, 24));
        //25 其中：坏账损失
        lrb.setQzhzssBnljje(getLrbBnljje(ewbhxhMap, 25));
        lrb.setQzhzssByje(getLrbByje(ewbhxhMap, 25));
        //26 无法收回的长期债券投资损失
        lrb.setWfshdcqzqtzssBnljje(getLrbBnljje(ewbhxhMap, 26));
        lrb.setWfshdcqzqtzssByje(getLrbByje(ewbhxhMap, 26));
        //27 无法收回的长期股权投资损失
        lrb.setWfshdcqgqtzssBnljje(getLrbBnljje(ewbhxhMap, 27));
        lrb.setWfshdcqgqtzssByje(getLrbByje(ewbhxhMap, 27));
        //28 自然灾害等不可抗力因素造成的损失
        lrb.setZrzhdbkklyszcdssBnljje(getLrbBnljje(ewbhxhMap, 28));
        lrb.setZrzhdbkklyszcdssByje(getLrbByje(ewbhxhMap, 28));
        //29 税收滞纳金
        lrb.setSsznjBnljje(getLrbBnljje(ewbhxhMap, 29));
        lrb.setSsznjByje(getLrbByje(ewbhxhMap, 29));
        //30 三、利润总额(亏损总额以–号填列)
        lrb.setSlrzekszeyhtlBnljje(getLrbBnljje(ewbhxhMap, 30));
        lrb.setSlrzekszeyhtlByje(getLrbByje(ewbhxhMap, 30));
        //31 减：所得税费用
        lrb.setJsdsfyBnljje(getLrbBnljje(ewbhxhMap, 31));
        lrb.setJsdsfyByje(getLrbByje(ewbhxhMap, 31));
        //32 四、净利润(净亏损以–号填列)
        lrb.setSjlrjksyhtlBnljje(getLrbBnljje(ewbhxhMap, 32));
        lrb.setSjlrjksyhtlByje(getLrbByje(ewbhxhMap, 32));
    }

    /**
     * 包装小企业会计准则现金流量表
     * @param xjllb
     * @param nsrForm
     * @param gridlbList
     */
    public static void wrapperXqykjzzXjllb(SbCwbbXqykjzzXjllb xjllb, NsrxxForm nsrForm, List<XqyxjllbnGridlb> gridlbList) {
        Map<String, XqyxjllbnGridlb> ewbhxhMap = gridlbList.stream().collect(Collectors.toMap(XqyxjllbnGridlb::getEwbhxh, Function.identity(), (e1, e2) -> e2));
        if (nsrForm != null) {
            try {
                if (StringUtils.isNotBlank(nsrForm.getBsrq())) {
                    xjllb.setBsrq(DateUtils.parseDate(nsrForm.getBsrq(), "yyyy-MM-dd"));
                }
            } catch (ParseException e) {
                log.error("日期转换有误:" + nsrForm.getBsrq());
            }
            xjllb.setBbssq(nsrForm.getBbssq());
        }
        xjllb.setSjcjSj(new Date());

        //1 销售产成品、商品、提供劳务收到的现金
        xjllb.setXsccpsptglwsddxjBnljje(getXjllbBnljje(ewbhxhMap, 1));
        xjllb.setXsccpsptglwsddxjByje(getXjllbByje(ewbhxhMap, 1));
        //2 收到的其他与经营活动有关的现金
        xjllb.setSdqtyjyhdygdxjBnljje(getXjllbBnljje(ewbhxhMap, 2));
        xjllb.setSdqtyjyhdygdxjByje(getXjllbByje(ewbhxhMap, 2));
        //3 购买原材料、商品、接受劳务支付的现金
        xjllb.setGmyclspjslwzfdxjBnljje(getXjllbBnljje(ewbhxhMap, 3));
        xjllb.setGmyclspjslwzfdxjByje(getXjllbByje(ewbhxhMap, 3));
        //4 支付的职工薪酬
        xjllb.setZfdzgxcBnljje(getXjllbBnljje(ewbhxhMap, 4));
        xjllb.setZfdzgxcByje(getXjllbByje(ewbhxhMap, 4));
        //5 支付的税费
        xjllb.setZfdsfBnljje(getXjllbBnljje(ewbhxhMap, 5));
        xjllb.setZfdsfByje(getXjllbByje(ewbhxhMap, 5));
        //6 支付的其他与经营活动有关的现金
        xjllb.setZfqtyjyhdygdxjBnljje(getXjllbBnljje(ewbhxhMap, 6));
        xjllb.setZfqtyjyhdygdxjByje(getXjllbByje(ewbhxhMap, 6));
        //7 经营活动产生的现金流量净额
        xjllb.setJyhdcsdxjlljeBnljje(getXjllbBnljje(ewbhxhMap, 7));
        xjllb.setJyhdcsdxjlljeByje(getXjllbByje(ewbhxhMap, 7));
        //8 收回短期投资、长期债券投资和长期股权投资收到的现金
        xjllb.setShdqtzcqzqtzhcqgqtzsddxjBnljje(getXjllbBnljje(ewbhxhMap, 8));
        xjllb.setShdqtzcqzqtzhcqgqtzsddxjByje(getXjllbByje(ewbhxhMap, 8));
        //9 取得投资收益收到的现金
        xjllb.setQdtzsysddxjBnljje(getXjllbBnljje(ewbhxhMap, 9));
        xjllb.setQdtzsysddxjByje(getXjllbByje(ewbhxhMap, 9));
        //10 处置固定资产、无形资产和其他非流动资产收回的现金净额
        xjllb.setCzgdzcwxzchqtfldzcshdxjjeBnljje(getXjllbBnljje(ewbhxhMap, 10));
        xjllb.setCzgdzcwxzchqtfldzcshdxjjeByje(getXjllbByje(ewbhxhMap, 10));
        //11 短期投资、长期债券投资和长期股权投资支付的现金
        xjllb.setDqtzcqzqtzhcqgqtzzfdxjBnljje(getXjllbBnljje(ewbhxhMap, 11));
        xjllb.setDqtzcqzqtzhcqgqtzzfdxjByje(getXjllbByje(ewbhxhMap, 11));
        //12 购建固定资产、无形资产和其他非流动资产支付的现金
        xjllb.setGjgdzcwxzchqtfldzczfdxjBnljje(getXjllbBnljje(ewbhxhMap, 12));
        xjllb.setGjgdzcwxzchqtfldzczfdxjByje(getXjllbByje(ewbhxhMap, 12));
        //13 投资活动产生的现金流量净额
        xjllb.setTzhdcsdxjlljeBnljje(getXjllbBnljje(ewbhxhMap, 13));
        xjllb.setTzhdcsdxjlljeByje(getXjllbByje(ewbhxhMap, 13));
        //14 取得借款收到的现金
        xjllb.setQdjksddxjBnljje(getXjllbBnljje(ewbhxhMap, 14));
        xjllb.setQdjksddxjByje(getXjllbByje(ewbhxhMap, 14));
        //15 吸收投资者投资收到的现金
        xjllb.setXstzztzsddxjBnljje(getXjllbBnljje(ewbhxhMap, 15));
        xjllb.setXstzztzsddxjByje(getXjllbByje(ewbhxhMap, 15));
        //16 偿还借款本金支付的现金
        xjllb.setChjkbjzfdxjBnljje(getXjllbBnljje(ewbhxhMap, 16));
        xjllb.setChjkbjzfdxjByje(getXjllbByje(ewbhxhMap, 16));
        //17 偿还借款利息支付的现金
        xjllb.setChjklxzfdxjBnljje(getXjllbBnljje(ewbhxhMap, 17));
        xjllb.setChjklxzfdxjByje(getXjllbByje(ewbhxhMap, 17));
        //18 分配利润支付的现金
        xjllb.setFplrzfdxjBnljje(getXjllbBnljje(ewbhxhMap, 18));
        xjllb.setFplrzfdxjByje(getXjllbByje(ewbhxhMap, 18));
        //19 筹资活动产生的现金流量净额
        xjllb.setCzhdcsdxjlljeBnljje(getXjllbBnljje(ewbhxhMap, 19));
        xjllb.setCzhdcsdxjlljeByje(getXjllbByje(ewbhxhMap, 19));
        //20 四、现金净增加额
        xjllb.setSxjjzjeBnljje(getXjllbBnljje(ewbhxhMap, 20));
        xjllb.setSxjjzjeByje(getXjllbByje(ewbhxhMap, 20));
        //21 加:期初现金余额
        xjllb.setJqcxjyeBnljje(getXjllbBnljje(ewbhxhMap, 21));
        xjllb.setJqcxjyeByje(getXjllbByje(ewbhxhMap, 21));
        //22 五、期末现金余额
        xjllb.setWqmxjyeBnljje(getXjllbBnljje(ewbhxhMap, 22));
        xjllb.setWqmxjyeByje(getXjllbByje(ewbhxhMap, 22));
    }

    /**
     * 包装小企业会计准则资产负债表
     * @param zcfzb
     * @param nsrForm
     * @param gridlbList
     */
    public static void wrapperXqykjzzZcfzb(SbCwbbXqykjzzZcfzb zcfzb, NsrxxForm nsrForm, List<XqyzcfzbGridlb> gridlbList) {
        Map<String, XqyzcfzbGridlb> ewbhxhMap = gridlbList.stream().collect(Collectors.toMap(XqyzcfzbGridlb::getEwbhxh, Function.identity(), (e1, e2) -> e2));
        if (nsrForm != null) {
            zcfzb.setBbssq(nsrForm.getBbssq());
        }
        zcfzb.setSjcjSj(new Date());
        
        //1 ZC:货币资金 QY:短期借款
        zcfzb.setHbzjQmyeZc(getZcfzQmyeZc(ewbhxhMap, 1));
        zcfzb.setHbzjNcyeZc(getZcfzNcyeZc(ewbhxhMap, 1));
        zcfzb.setDqjkQmyeQy(getZcfzQmyeQy(ewbhxhMap, 1));
        zcfzb.setDqjkNcyeQy(getZcfzNcyeQy(ewbhxhMap, 1));
        //2 ZC:短期投资 QY:应付票据
        zcfzb.setDqtzQmyeZc(getZcfzQmyeZc(ewbhxhMap, 2));
        zcfzb.setDqtzNcyeZc(getZcfzNcyeZc(ewbhxhMap, 2));
        zcfzb.setYfpjQmyeQy(getZcfzQmyeQy(ewbhxhMap, 2));
        zcfzb.setYfpjNcyeQy(getZcfzNcyeQy(ewbhxhMap, 2));
        //3 ZC:应收票据 QY:应付账款
        zcfzb.setYspjQmyeZc(getZcfzQmyeZc(ewbhxhMap, 3));
        zcfzb.setYspjNcyeZc(getZcfzNcyeZc(ewbhxhMap, 3));
        zcfzb.setYfzkQmyeQy(getZcfzQmyeQy(ewbhxhMap, 3));
        zcfzb.setYfzkNcyeQy(getZcfzNcyeQy(ewbhxhMap, 3));
        //4 ZC:应收账款 QY:预收账款
        zcfzb.setYszkQmyeZc(getZcfzQmyeZc(ewbhxhMap, 4));
        zcfzb.setYszkNcyeZc(getZcfzNcyeZc(ewbhxhMap, 4));
        zcfzb.setYszkQmyeQy(getZcfzQmyeQy(ewbhxhMap, 4));
        zcfzb.setYszkNcyeQy(getZcfzNcyeQy(ewbhxhMap, 4));
        //5 ZC:预付账款 QY:应付职工薪酬
        zcfzb.setYfzkQmyeZc(getZcfzQmyeZc(ewbhxhMap, 5));
        zcfzb.setYfzkNcyeZc(getZcfzNcyeZc(ewbhxhMap, 5));
        zcfzb.setYfzgxcQmyeQy(getZcfzQmyeQy(ewbhxhMap, 5));
        zcfzb.setYfzgxcNcyeQy(getZcfzNcyeQy(ewbhxhMap, 5));
        //6 ZC:应收股利 QY:应交税费
        zcfzb.setYsglQmyeZc(getZcfzQmyeZc(ewbhxhMap, 6));
        zcfzb.setYsglNcyeZc(getZcfzNcyeZc(ewbhxhMap, 6));
        zcfzb.setYjsfQmyeQy(getZcfzQmyeQy(ewbhxhMap, 6));
        zcfzb.setYjsfNcyeQy(getZcfzNcyeQy(ewbhxhMap, 6));
        //7 ZC:应收利息 QY:应付利息
        zcfzb.setYslxQmyeZc(getZcfzQmyeZc(ewbhxhMap, 7));
        zcfzb.setYslxNcyeZc(getZcfzNcyeZc(ewbhxhMap, 7));
        zcfzb.setYflxQmyeQy(getZcfzQmyeQy(ewbhxhMap, 7));
        zcfzb.setYflxNcyeQy(getZcfzNcyeQy(ewbhxhMap, 7));
        //8 ZC:其他应收款 QY:应付利润
        zcfzb.setQtyskQmyeZc(getZcfzQmyeZc(ewbhxhMap, 8));
        zcfzb.setQtyskNcyeZc(getZcfzNcyeZc(ewbhxhMap, 8));
        zcfzb.setYflrQmyeQy(getZcfzQmyeQy(ewbhxhMap, 8));
        zcfzb.setYflrNcyeQy(getZcfzNcyeQy(ewbhxhMap, 8));
        //9 ZC:存货 QY:其他应付款
        zcfzb.setChQmyeZc(getZcfzQmyeZc(ewbhxhMap, 9));
        zcfzb.setChNcyeZc(getZcfzNcyeZc(ewbhxhMap, 9));
        zcfzb.setQtyfkQmyeQy(getZcfzQmyeQy(ewbhxhMap, 9));
        zcfzb.setQtyfkNcyeQy(getZcfzNcyeQy(ewbhxhMap, 9));
        //10 ZC:其中:原材料 QY:其他流动负债
        zcfzb.setQzyclQmyeZc(getZcfzQmyeZc(ewbhxhMap, 10));
        zcfzb.setQzyclNcyeZc(getZcfzNcyeZc(ewbhxhMap, 10));
        zcfzb.setQtldfzQmyeQy(getZcfzQmyeQy(ewbhxhMap, 10));
        zcfzb.setQtldfzNcyeQy(getZcfzNcyeQy(ewbhxhMap, 10));
        //11 ZC:在产品 QY:流动负债合计
        zcfzb.setZcpQmyeZc(getZcfzQmyeZc(ewbhxhMap, 11));
        zcfzb.setZcpNcyeZc(getZcfzNcyeZc(ewbhxhMap, 11));
        zcfzb.setLdfzhjQmyeQy(getZcfzQmyeQy(ewbhxhMap, 11));
        zcfzb.setLdfzhjNcyeQy(getZcfzNcyeQy(ewbhxhMap, 11));
        //12 ZC:库存商品 QY:
        zcfzb.setKcspQmyeZc(getZcfzQmyeZc(ewbhxhMap, 12));
        zcfzb.setKcspNcyeZc(getZcfzNcyeZc(ewbhxhMap, 12));
        //13 ZC:周转材料 QY:长期借款
        zcfzb.setZzclQmyeZc(getZcfzQmyeZc(ewbhxhMap, 13));
        zcfzb.setZzclNcyeZc(getZcfzNcyeZc(ewbhxhMap, 13));
        zcfzb.setCqjkQmyeQy(getZcfzQmyeQy(ewbhxhMap, 13));
        zcfzb.setCqjkNcyeQy(getZcfzNcyeQy(ewbhxhMap, 13));
        //14 ZC:其他流动资产 QY:长期应付款
        zcfzb.setQtldzcQmyeZc(getZcfzQmyeZc(ewbhxhMap, 14));
        zcfzb.setQtldzcNcyeZc(getZcfzNcyeZc(ewbhxhMap, 14));
        zcfzb.setCqyfkQmyeQy(getZcfzQmyeQy(ewbhxhMap, 14));
        zcfzb.setCqyfkNcyeQy(getZcfzNcyeQy(ewbhxhMap, 14));
        //15 ZC:流动资产合计 QY:递延收益
        zcfzb.setLdzchjQmyeZc(getZcfzQmyeZc(ewbhxhMap, 15));
        zcfzb.setLdzchjNcyeZc(getZcfzNcyeZc(ewbhxhMap, 15));
        zcfzb.setDysyQmyeQy(getZcfzQmyeQy(ewbhxhMap, 15));
        zcfzb.setDysyNcyeQy(getZcfzNcyeQy(ewbhxhMap, 15));
        //16 ZC: QY:其他非流动负债
        zcfzb.setQtfldfzQmyeQy(getZcfzQmyeQy(ewbhxhMap, 16));
        zcfzb.setQtfldfzNcyeQy(getZcfzNcyeQy(ewbhxhMap, 16));
        //17 ZC:长期债券投资 QY:非流动负债合计
        zcfzb.setCqzqtzQmyeZc(getZcfzQmyeZc(ewbhxhMap, 17));
        zcfzb.setCqzqtzNcyeZc(getZcfzNcyeZc(ewbhxhMap, 17));
        zcfzb.setFldfzhjQmyeQy(getZcfzQmyeQy(ewbhxhMap, 17));
        zcfzb.setFldfzhjNcyeQy(getZcfzNcyeQy(ewbhxhMap, 17));
        //18 ZC:长期股权投资 QY:负债合计
        zcfzb.setCqgqtzQmyeZc(getZcfzQmyeZc(ewbhxhMap, 18));
        zcfzb.setCqgqtzNcyeZc(getZcfzNcyeZc(ewbhxhMap, 18));
        zcfzb.setFzhjQmyeQy(getZcfzQmyeQy(ewbhxhMap, 18));
        zcfzb.setFzhjNcyeQy(getZcfzNcyeQy(ewbhxhMap, 18));
        //19 ZC:固定资产原价 QY:
        zcfzb.setGdzcyjQmyeZc(getZcfzQmyeZc(ewbhxhMap, 19));
        zcfzb.setGdzcyjNcyeZc(getZcfzNcyeZc(ewbhxhMap, 19));
        //20 ZC:减:累计折旧 QY:
        zcfzb.setJljzjQmyeZc(getZcfzQmyeZc(ewbhxhMap, 20));
        zcfzb.setJljzjNcyeZc(getZcfzNcyeZc(ewbhxhMap, 20));
        //21 ZC:固定资产账面价值 QY:
        zcfzb.setGdzczmjzQmyeZc(getZcfzQmyeZc(ewbhxhMap, 21));
        zcfzb.setGdzczmjzNcyeZc(getZcfzNcyeZc(ewbhxhMap, 21));
        //22 ZC:在建工程 QY:
        zcfzb.setZjgcQmyeZc(getZcfzQmyeZc(ewbhxhMap, 22));
        zcfzb.setZjgcNcyeZc(getZcfzNcyeZc(ewbhxhMap, 22));
        //23 ZC:工程物资 QY:
        zcfzb.setGcwzQmyeZc(getZcfzQmyeZc(ewbhxhMap, 23));
        zcfzb.setGcwzNcyeZc(getZcfzNcyeZc(ewbhxhMap, 23));
        //24 ZC:固定资产清理 QY:
        zcfzb.setGdzcqlQmyeZc(getZcfzQmyeZc(ewbhxhMap, 24));
        zcfzb.setGdzcqlNcyeZc(getZcfzNcyeZc(ewbhxhMap, 24));
        //25 ZC:生产性生物资产 QY:
        zcfzb.setScxswzcQmyeZc(getZcfzQmyeZc(ewbhxhMap, 25));
        zcfzb.setScxswzcNcyeZc(getZcfzNcyeZc(ewbhxhMap, 25));
        //26 ZC:无形资产 QY:实收资本(或股本)
        zcfzb.setWxzcQmyeZc(getZcfzQmyeZc(ewbhxhMap, 26));
        zcfzb.setWxzcNcyeZc(getZcfzNcyeZc(ewbhxhMap, 26));
        zcfzb.setSszbhgbQmyeQy(getZcfzQmyeQy(ewbhxhMap, 26));
        zcfzb.setSszbhgbNcyeQy(getZcfzNcyeQy(ewbhxhMap, 26));
        //27 ZC:开发支出 QY:资本公积
        zcfzb.setKfzcQmyeZc(getZcfzQmyeZc(ewbhxhMap, 27));
        zcfzb.setKfzcQmyeZc(getZcfzNcyeZc(ewbhxhMap, 27));
        zcfzb.setZbgjQmyeQy(getZcfzQmyeQy(ewbhxhMap, 27));
        zcfzb.setZbgjNcyeQy(getZcfzNcyeQy(ewbhxhMap, 27));
        //28 ZC:长期待摊费用 QY:盈余公积
        zcfzb.setCqdtfyQmyeZc(getZcfzQmyeZc(ewbhxhMap, 28));
        zcfzb.setCqdtfyNcyeZc(getZcfzNcyeZc(ewbhxhMap, 28));
        zcfzb.setYygjQmyeQy(getZcfzQmyeQy(ewbhxhMap, 28));
        zcfzb.setYygjNcyeQy(getZcfzNcyeQy(ewbhxhMap, 28));
        //29 ZC:其他非流动资产 QY:未分配利润
        zcfzb.setQtfldzcQmyeZc(getZcfzQmyeZc(ewbhxhMap, 29));
        zcfzb.setQtfldzcNcyeZc(getZcfzNcyeZc(ewbhxhMap, 29));
        zcfzb.setWfplrQmyeQy(getZcfzQmyeQy(ewbhxhMap, 29));
        zcfzb.setWfplrNcyeQy(getZcfzNcyeQy(ewbhxhMap, 29));
        //30 ZC:非流动资产合计 QY:所有者权益(或股东权益)合计
        zcfzb.setFldzchjQmyeZc(getZcfzQmyeZc(ewbhxhMap, 30));
        zcfzb.setFldzchjNcyeZc(getZcfzNcyeZc(ewbhxhMap, 30));
        zcfzb.setSyzqyhgdqyhjQmyeQy(getZcfzQmyeQy(ewbhxhMap, 30));
        zcfzb.setSyzqyhgdqyhjNcyeQy(getZcfzNcyeQy(ewbhxhMap, 30));
        //31 ZC:资产合计 QY:负债和所有者权益(或股东权益)总计
        zcfzb.setZczjQmyeZc(getZcfzQmyeZc(ewbhxhMap, 31));
        zcfzb.setZczjNcyeZc(getZcfzNcyeZc(ewbhxhMap, 31));
        zcfzb.setFzhsyzqyhgdqyzjQmyeQy(getZcfzQmyeQy(ewbhxhMap, 31));
        zcfzb.setFzhsyzqyhgdqyzjNcyeQy(getZcfzNcyeQy(ewbhxhMap, 31));
    }

    /**
     * 利润表-本月（季）金额
     */
    public static Double getLrbByje(Map<String, XqylrbnbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        XqylrbnbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getByje());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("利润表第{}行数据没有Byje,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
    /**
     * 利润表-本年累计金额
     */
    public static Double getLrbBnljje(Map<String, XqylrbnbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        XqylrbnbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getBnljje());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("利润表第{}行数据没有Bnljje,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
    /**
     * 现金流量表-本月（季）金额
     */
    public static Double getXjllbByje(Map<String, XqyxjllbnGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        XqyxjllbnGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getByje());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("现金流量表第{}行数据没有Byje,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
    /**
     * 现金流量表-本年累计金额
     */
    public static Double getXjllbBnljje(Map<String, XqyxjllbnGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        XqyxjllbnGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getBnljje());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("现金流量表第{}行数据没有Bnljje,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表 - 期末余额资产
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzQmyeZc(Map<String, XqyzcfzbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        XqyzcfzbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getQmyeZc());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有qmyeZc,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表 - 年初余额资产
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzNcyeZc(Map<String, XqyzcfzbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        XqyzcfzbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getNcyeZc());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有ncyeZc,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
    /**
     * 资产负债表 - 期末余额权益
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzQmyeQy(Map<String, XqyzcfzbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        XqyzcfzbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getQmyeQy());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有qmyeQy,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表 - 期末余额权益
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzNcyeQy(Map<String, XqyzcfzbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        XqyzcfzbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getNcyeQy());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有ncsQy,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
}
